package com.bw.router

import com.alibaba.android.arouter.facade.Postcard
import com.alibaba.android.arouter.facade.callback.NavigationCallback


/**
 * 局部跳转的降级策略,解决页面找不到的政策
 */
class LocalDegradeService constructor(private val path:String = "",private val group:String=""): NavigationCallback{
    private var defalutGroup:String="empty"
    private var defalutPath:String ="/empty/activity"

    //匹配到目标页面
    override fun onFound(postcard: Postcard?) {

    }
    //未匹配到目标页面
    override fun onLost(postcard: Postcard) {
        //默认
        if (!path.isNullOrEmpty()){
            defalutPath = path as String
        }
        if(!group.isNullOrEmpty()){
            defalutGroup = group as String
        }

        postcard.group = defalutGroup
        postcard.path=defalutPath
        postcard.navigation()
    }
    //已经跳转页面成功
    override fun onArrival(postcard: Postcard?) {

    }
    //页面跳转被拦截
    override fun onInterrupt(postcard: Postcard?) {

    }


}